package com.hs.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtil
{
	public static String getDate()
	{
		Date Date = new Date(); 
		SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
		String strDate = fmt.format(Date);
		
		return strDate;
	}
	
	public static int getElapsedDay( String _strDate )
	{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date currDate = new Date();
		Date startDate;
		try
		{
			startDate = sdf.parse(_strDate);
			long lCurrDate = currDate.getTime();
			long lStartDate = startDate.getTime();
			long lMinusDate = lCurrDate - lStartDate;
			
			return (int)(lMinusDate / (1000*60*60*24));
		}
		catch( ParseException e )
		{
			e.printStackTrace();
		} // end catch( ParseException e )
		
		return 0;
	}
	
	public static int getElapsedWeek(String _strDate)
	{
		return getElapsedDay(_strDate) / 7;
	}
	
	public static int getCurrentHour()
	{
		Calendar c = Calendar.getInstance();
    	return c.get(Calendar.HOUR_OF_DAY);
	}
	
}
